package com.aqie.haikang.dorm.service.impl;

import com.aqie.haikang.dorm.dao.CronRepository;
import com.aqie.haikang.dorm.dao.aqie.CronExpression;
import com.aqie.haikang.dorm.entity.Cron;
import com.aqie.haikang.dorm.service.ICronService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author aqie
 * @Date 2021/12/11 14:08
 * @desc
 */
@Service
public class CronServiceImpl implements ICronService {
    @Autowired
    private CronRepository cronRepository;

    @Override
    public String getCronByName(String name) {
        CronExpression byName = cronRepository.getByName(name);
        return byName.getCron();
    }

    @Override
    public List<Cron> list() {
        return cronRepository.findAllByStatus(0);
    }
}
